<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" type="image/gif" href="slike/animated_favicon1.gif">
<script src="skripte/Cookies.js"></script>
<script src="skripte/proba1.js"></script>
<script src="jQuery/jquery-1.10.2.js"></script>
<script src="skripte/urlParam.js"></script>
<script src="skripte/WSPermisije.js"></script>

<LINK href="stilovi/coda-slider.css" rel="stylesheet" type="text/css">
<LINK href="stilovi/templatemo_style.css" rel="stylesheet" type="text/css">
<script src="skripte/WSRole.js" charset="UTF-8"></script>
<link rel="icon" type="image/gif" href="slike/animated_favicon1.gif">
<LINK href="stilovi/srednjeDugme.css" rel="stylesheet" type="text/css">
<LINK href="stilovi/role.css" rel="stylesheet" type="text/css">
<LINK href="stilovi/navigacija.css" rel="stylesheet" type="text/css">
<script src="skripte/kreirajNavigaciju.js" charset="UTF-8"/></script>
<title>Permisije</title>

</head>
<body>

<div id="slider">
 
	<div id="templatemo_main">
    	<ul id="social_box">
            <h1> Javna saobraćajna mreža Bosne i Hercegovine </h1>         
        </ul>
        
        <div id="content">
     
            <div class="scroll">
                <div class="scrollContainer">
                
                    <div class="panel" id="home">             
                        <div id="navigacija"></div>
							<div id="korisnik">
								<p>Rola:</p>
							</div>
							<h4>Permisije za rolu:</h4>
							<div id="sve_role" >
								<table id="tblRole" border=0 align="left">
								</table>
							</div>
							<br>&nbsp;<br>
							<div id="dugmeDiv" align="left" style="clear:both">
								<button type="button" onclick="novaPermisija()">Nova</button>
								<button type="button"  onclick="updatePermisiju()">Spremi Izmjene</button>
							</div>
							<div id="nova_Rola" style="visibility: hidden;clear:both;" >
								<form name="forma1">
								<input type="text" id="nazivR">
								<button type="button" id="addR" onClick="upisiPermisiju()">Dodaj novu permisiju</button>
								</form>
							</div>
							<script>
								navigacija();
								$('#rolaP').append("<b>"+GetURLParameter('rola')+"</b>");
								var rola=GetURLParameter('rola');
								var permisije=new Array();
								var chek=new Array();
								
								function novaPermisija()
								{
									$('#nova_Rola').css("visibility","visible");
								}
								function upisiPermisiju()
								{
									var ulaz=$('#nazivR').val();
									kreirajPermisiju(ulaz,rola);
									
								}
								function updatePermisiju()
								{
									var sveUredu=true;
									for(var i=0;i<permisije.length;i++)
										{
										spremiIzmjenePermisije(permisije[i],rola,$('input[name='+permisije[i]+']').prop('checked'))
										}
									if(sveUredu) alert("Izmjene su spašene u bazu!");
								}
								function insertPermisije(arg,chekiran)
								{
									permisije.push(arg);
									chek.push(chekiran);
									
									$('#tblRole').append("<tr><td><input type='checkbox' name='"+arg+"' value='"+arg+"'>"+arg+"</td></tr>");
									
									if(chekiran=='true')
										{
										$('input[name='+arg+']').prop('checked',true);
										
										}
										
									$('#nova_Rola').css("visibility","hidden");
								}
						
								ucitajPermisije(rola);
							</script>
				    </div> 
        	    </div>
        	</div>
 		</div>
    </div> 
</div>

</body>
</html>